package com.mall.controller;

import com.mall.result.Result;
import com.mall.service.WorkSpaceService;
import com.mall.vo.BusinessDataVO;
import com.mall.vo.OverviewBrandsVO;
import com.mall.vo.OverviewGoodsVO;
import com.mall.vo.OverviewOrdersVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDateTime;
import java.time.LocalTime;

@RestController
@RequestMapping("/admin/workspace")
@RequiredArgsConstructor
@Slf4j
@Api(tags = "工作台相关接口")
public class WorkSpaceController {

    private final WorkSpaceService workSpaceService;

    /**
     * 查询今日运营数据
     * @return
     */
    @GetMapping("/businessData")
    @ApiOperation("查询今日运营数据")
    public Result<BusinessDataVO> getBusinessData() {
        log.info("查询今日运营数据");
        LocalDateTime begin = LocalDateTime.now().with(LocalTime.MIN);
        LocalDateTime end = LocalDateTime.now().with(LocalTime.MAX);
        return Result.success(workSpaceService.getBusinessData(begin, end));
    }

    /**
     * 查询今日订单管理数据
     * @return
     */
    @GetMapping("/overviewOrders")
    @ApiOperation("查询今日订单管理数据")
    public Result<OverviewOrdersVO> getOverviewOrders() {
        log.info("查询今日订单管理数据");
        return Result.success(workSpaceService.getOverviewOrders());
    }

    /**
     * 查询今日品牌数据
     * @return
     */
    @GetMapping("/overviewBrands")
    @ApiOperation("查询今日品牌数据")
    public Result<OverviewBrandsVO> getOverviewBrands() {
        log.info("查询今日品牌数据");
        OverviewBrandsVO overviewBrandsVO = workSpaceService.getOverviewBrands();
        return Result.success(overviewBrandsVO);
    }

    @GetMapping("/overviewGoods")
    @ApiOperation("查询今日商品数据")
    public Result<OverviewGoodsVO> getOverviewGoods() {
        log.info("查询今日商品数据");
        OverviewGoodsVO overviewGoodsVO = workSpaceService.getOverviewGoods();
        return Result.success(overviewGoodsVO);
    }
}
